package com.platform.api;

import com.platform.annotation.IgnoreAuth;
import com.platform.service.ApiSchoolService;
import com.platform.util.ApiBaseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zhanghao
 */
@Api(tags = "学校管理")
@RestController
@RequestMapping("/api/school")
public class ApiSchoolController extends ApiBaseAction {

    @Autowired
    private ApiSchoolService schoolService;

    /**
     * 查询城市列表
     */
    @ApiOperation(value = "查询城市列表", response = Map.class)
    @PostMapping("cityList")
    @IgnoreAuth
    public Object cityList() {
        return toResponsSuccess(schoolService.queryCityList());
    }

    /**
     * 查询学校列表
     */
    @ApiOperation(value = "查询学校列表", response = Map.class)
    @PostMapping("schoolList")
    @IgnoreAuth
    public Object schoolList(@RequestParam Integer id) {
        return toResponsSuccess(schoolService.querySchoolList(id));
    }

    /**
     * 搜索学校
     */
    @ApiOperation(value = "搜索学校", response = Map.class)
    @GetMapping("queryLikeName")
    @IgnoreAuth
    public Object queryLikeName(@RequestParam String schoolName) {
        return toResponsSuccess(schoolService.queryLikeName(schoolName));
    }

    /**
     * 查询学校寝室楼
     */
    @ApiOperation(value = "查询学校寝室楼", response = Map.class)
    @PostMapping("queryBuildings")
    @IgnoreAuth
    public Object queryBuildings(@RequestParam Integer schoolId) {
        return toResponsSuccess(schoolService.queryBuildings(schoolId));
    }
}